package com.atguigu.exam;

/**
 * @author xbd
 * @create 2021-05-26 21:06
 */
public class ColorTest {
    public static void main(String[] args) {
        Color colorone = Color.GREEN;
        System.out.println(colorone);
        colorone.meaning();
        System.out.println("************");
        Color[] colors = Color.values();
        for (int i = 0; i < colors.length; i++) {
            System.out.println(colors[i]);
            colors[i].meaning();
        }
    }
}

interface show{
    void meaning();
}

enum Color implements show{
    RED(255,0,0){
        @Override
        public void meaning() {
            System.out.println("红色");
        }
    },
    BLUE(0,0,255) {
        @Override
        public void meaning() {
            System.out.println("蓝色");
        }
    },
    BLACK(0,0,0) {
        @Override
        public void meaning() {
            System.out.println("黑色");
        }
    },
    YELLOW(255,255,0) {
        @Override
        public void meaning() {
            System.out.println("黄色");
        }
    },
    GREEN(0,255,0) {
        @Override
        public void meaning() {
            System.out.println("绿色");
        }
    };

    private final int redValue;
    private final int greenValue;
    private final int blueValue;

    private Color(int redValue, int greenValue, int blueValue) {
        this.redValue = redValue;
        this.greenValue = greenValue;
        this.blueValue = blueValue;
    }

    @Override
    public String toString() {
        return "Color{" +
                "redValue=" + redValue +
                ", greenValue=" + greenValue +
                ", blueValue=" + blueValue +
                '}';
    }

}